package com.chinabank.client;

import com.chinabank.client.netty.BootNettyClientThread;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;

/**
 * 蚂蚁舞
 */
@SpringBootApplication
@EnableAsync
@EnableScheduling
public class BootNettyClientApplication implements CommandLineRunner{
    public static void main( String[] args ) {
        SpringApplication app = new SpringApplication(BootNettyClientApplication.class);
        app.run(args);

        System.out.println( "Hello World!" );
    }

    @Async
    @Override
    public void run(String... args) throws Exception {
        /**
         * 使用异步注解方式启动netty客户端服务
         */
        int port = 38010;
        String address = "192.168.2.115";
        int count = 1; // 模拟多个客户端
        for(int i = 0; i < count; i++) {
            BootNettyClientThread thread = new BootNettyClientThread(port, address);
            thread.start();
        }

    }
}